package com.only4play.practice.park.core.service.impl;

import com.only4play.codegen.support.model.JsonObject;
import com.only4play.practice.park.core.entity.Park;
import com.only4play.practice.park.core.entity.PkParkingCar;
import com.only4play.practice.park.core.model.req.ConfirmEnterParkReq;
import com.only4play.practice.park.core.model.req.RequestEnterParkReq;
import com.only4play.practice.park.core.model.vo.CarEnterRecordVo;
import com.only4play.practice.park.core.service.CarEnterParkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author mengdy
 */
@Slf4j
@Service
public class CarEnterParkServiceImpl implements CarEnterParkService {

    /**
     * 车辆请求入场，检查是否符合入场条件
     * @param requestEnterParkReq 请求入参
     * @return 返回结果
     */
    @Override
    public JsonObject<String> requestEnterPark(RequestEnterParkReq requestEnterParkReq) {
        return null;
    }

    @Override
    public JsonObject<PkParkingCar> confirmEnterPark(ConfirmEnterParkReq confirmEnterParkReq) {

        log.info("[confirmEnterPark]...确认车辆入场参数 = {}", confirmEnterParkReq);

        // 必要参数状态校验

        Park park = new Park();

        /*############################## 生成车辆入库记录 #######################*/
        CarEnterRecordVo result = buildCarEnterRecord(confirmEnterParkReq,park);
        PkParkingCar pkParkingCar = result.getPkParkingCar();
        // 车辆入场数据推送


        return JsonObject.success(pkParkingCar);
    }

    private CarEnterRecordVo buildCarEnterRecord(ConfirmEnterParkReq confirmEnterParkReq, Park park) {

        log.info("[buildCarEnterRecord]...生成车辆入场记录");


        log.info("[buildCarEnterRecord]...生成场内车辆记录");

        CarEnterRecordVo carEnterRecordVo = new CarEnterRecordVo();
        return carEnterRecordVo;
    }
}
